package com.tvein.sanguo.zone.controller
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.zone.model.SystemProxy;
	import com.tvein.sanguo.zone.view.ZoneMediator;
//
	public class ZoneInit extends SimpleFabricationCommand implements ICommand
	{
		private var systemData:SystemProxy;
		private var zoneMediator:ZoneMediator;
		
		override public function execute(notification:INotification) : void
		{
			systemData = facade.retrieveProxy(SystemProxy.NAME) as SystemProxy;
			zoneMediator = facade.retrieveMediator(ZoneMediator.NAME) as ZoneMediator;
			
			switch(notification.getBody()[0])
			{
				case "srcServer":
					systemData.srcServer = notification.getBody()[1];
					break;
				case "musicVol":
					systemData.musicVol = notification.getBody()[1];
					systemData.transform.volume = systemData.musicVol * .01;
					systemData.channel.soundTransform = systemData.transform;
					break;
				case "mute":
					if (notification.getBody()[1] == "on")
					{
						systemData.channel.stop();
						systemData.musicMute = true;
					}
					else
					{
						systemData.musicMute = false;
					}
					break;
				case "show":
					zoneMediator.zone.visible = notification.getBody()[1];
					break;
			}
		}
	}
}